package com.mate.cloud.datascope.controller;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mate.cloud.core.response.BaseResponse;
import com.mate.cloud.core.web.controller.AdminBaseController;
import com.mate.cloud.datascope.domain.Order;
import com.mate.cloud.datascope.query.OrderQuery;
import com.mate.cloud.datascope.service.OrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 数据权限验证
 *
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2024/5/27 16:52
 * @updateUser: MI
 * @updateTime: 2024/5/27 16:52
 * @updateRemark: 修改内容
 * @version: v1.0
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/order")
public class OrderController extends AdminBaseController {


    private final OrderService orderService;

    @PostMapping("/list")
    public BaseResponse list(@RequestBody OrderQuery query) {
        log.info("===============OrderController#list==============={}", JSON.toJSONString(query));
        Page page = new Page<>(query.getCurrent(), query.getSize());
        List<Order> orders = orderService.orders(page,query);
        IPage orderPage = page.setRecords(orders);
        return successBodyResponse(orderPage);
    }

}
